package com.example.demo.properties;

import com.example.demo.model.Student;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/proper")
public class PropertiesController {
    @Value("${server.port}")
    private Integer port;

    @Autowired
    private DataConfig data;
    public Integer getPort() {
        return port;
    }
    @RequestMapping("/getPort")
    @ResponseBody
    public String getPortValue(){
        return "port:"+port+"\n"+"data: "+data.url;
    }
    @Value("${mykey.key1}")
    private Integer key1;
    @RequestMapping("/getKey")
    public Integer getKey1(){
        return key1;
    }

    @Value("${string.value}")
    private String value;

    @RequestMapping("/getValue")
    public String getValue(){
        System.out.println(value);
        return value;
    }

    @Autowired
    private Stu stu;

    @RequestMapping("/getStu")
    public String getStu(){
        return  stu.toString();
    }

    @Autowired
    private StuMap1 stuMap1;

    @RequestMapping("/getStu2")
    public String getStu2(){
        return  stuMap1.toString();
    }

    @Autowired
    private  StuMap2 stuMap2;
    @RequestMapping("getMap2")
    public String getMap2(){
        return stuMap2.toString();
    }

    @Resource(name = "dataTypes")
    private DataTypes ku;
    @RequestMapping("getDataTypes")
    public String getDataTypes(){
        return ku.toString();
    }


}
